package chamster.random;

import java.util.Map;

import chamster.TurnWithChanceHamster;
import chamster.actions.ForewardAction;
import chamster.actions.HamsterAction;

public class TurnWithChanceRandomMachine 
extends RandomStatelessActionMachine<TurnWithChanceHamster> {

	private final double forewardMultiplier;
	
	public TurnWithChanceRandomMachine(
			Map<HamsterAction<TurnWithChanceHamster>, Integer> actions,
			double forewardMultiplier) {
		super(actions);
		this.forewardMultiplier = forewardMultiplier;
	}

	@Override
	protected int newChance(HamsterAction<TurnWithChanceHamster> executedAction,
			int oldChance) {
		if(executedAction instanceof ForewardAction) {
			return (int)Math.max(1, Math.round(oldChance * this.forewardMultiplier));
		}
		return oldChance;
	}

}
